/**
 * Copyright (c) 2013-2022 Nikita Koksharov
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.redisson.client.protocol.convertor;


/**
 * 该类实现了Convertor接口，用于将对象转换为长整型(Long)的位数。
 * 具体来说，它将输入的对象转换为长整型，并乘以8，以表示该长整型数值在二进制中所占的位数。
 */
public class BitsSizeReplayConvertor implements Convertor<Long> {

    /**
     * 转换给定的对象为长整型的位数。
     * 如果输入对象为null，则返回null。
     * 否则，将输入对象强制转换为长整型，并乘以8，返回结果。
     *
     * @param obj 待转换的对象，预期为长整型或可转换为长整型的类型。
     * @return 转换后的长整型数值，表示原数值在二进制中所占的位数，如果输入为null则返回null。
     */
    @Override
    public Long convert(Object obj) {
        if (obj == null) {
            return null;
        }
        return ((Long) obj) * 8;
    }

}
